#include <stdio.h>  
  
int dx[8] = {1, 1, 1, -1, -1, -1, 0, 0};  
  
int dy[8] = {1, -1, 0, 1, -1, 0, 1, -1};  
int cnt[105][105];  
  
int main() {  
    int n, m, cnt0 = 0;  
    char s[105][105];  
    while (scanf("%d%d", &n, &m)) {  
        getchar();  
        cnt0++;  
        if (n == m && n == 0)  
            break;  
        if (cnt0 != 1)  
            putchar('\n');  
        for (int i = 1; i <= n; i++) {  
            for (int j = 1; j <= m; j++)  
                if (scanf("%c", &s[i][j]));  
            getchar();  
        }  
        for (int i = 1; i <= n; i++)  
            for (int j = 1; j <= m; j++)  
                for (int k = 0; k < 8; k++) {  
                    if (s[i][j] == '*')  
                        break;  
                    if (s[i + dx[k]][j + dy[k]] == '*')  
                        cnt[i][j]++;  
                }  
        printf("Field #%d:\n", cnt0);  
        for (int i = 1; i <= n; i++) {  
            for (int j = 1; j <= m; j++) {  
                if (s[i][j] == '*')  
                    putchar('*');  
                else  
                    printf("%d", cnt[i][j]);  
            }  
            putchar('\n');  
        }  
        for (int i = 0; i <= n + 1; i++)  
            for (int j = 0; j <= m + 1; j++){  
                cnt[i][j] = 0;    
                s[i][j] = '.';            
            }  
  
    }  
    return 0;  
}  